﻿using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Debug;
using OpenAuth.Repository.Domain;

namespace OpenAuth.Repository
{
    public partial class OpenAuthDBContext : DbContext
    {

        public static readonly LoggerFactory LoggerFactory = new LoggerFactory(new[] { new DebugLoggerProvider((_, __) => true) });
        public OpenAuthDBContext(DbContextOptions<OpenAuthDBContext> options)
            : base(options)
        { }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
            optionsBuilder.UseLoggerFactory(LoggerFactory);
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //modelBuilder.Entity<UploadFile>().HasOne<InspectRecordItem>(u => u.InspectRecordItem).WithMany(u => u.UploadFiles)
            //    .HasForeignKey(u => u.FileGuid);

            //modelBuilder.Entity<InspectRecordItem>().HasMany(u => u.UploadFiles).WithOne(u => u.InspectRecordItem)
            //    .HasForeignKey(u => u.FileGuid);
        }

        public virtual DbSet<Application> Applications { get; set; }
        public virtual DbSet<Category> Categories { get; set; }
        public virtual DbSet<CategoryType> CategoryTypes { get; set; }
        public virtual DbSet<FlowInstance> FlowInstances { get; set; }
        public virtual DbSet<FlowInstanceOperationHistory> FlowInstanceOperationHistorys { get; set; }
        public virtual DbSet<FlowInstanceTransitionHistory> FlowInstanceTransitionHistorys { get; set; }
        public virtual DbSet<FlowScheme> FlowSchemes { get; set; }
        public virtual DbSet<Form> Forms { get; set; }
        public virtual DbSet<Module> Modules { get; set; }
        public virtual DbSet<ModuleElement> ModuleElements { get; set; }
        public virtual DbSet<Org> Orgs { get; set; }
        public virtual DbSet<Relevance> Relevances { get; set; }
        public virtual DbSet<Resource> Resources { get; set; }
        public virtual DbSet<Role> Roles { get; set; }
        public virtual DbSet<User> Users { get; set; }
        public virtual DbSet<UploadFile> UploadFiles { get; set; }

        public virtual DbSet<FrmLeaveReq> FrmLeaveReqs { get; set; }

        public virtual DbSet<InspectArea> InspectAreas { get; set; }
        public virtual DbSet<InspectStandard> InspectStandards { get; set; }
        public virtual DbSet<InspectStandardItems> InspectStandardItems { get; set; }

        public virtual DbSet<InspectPlan> InspectPlans { get; set; }

        public virtual DbSet<InspectPlanContent> InspectPlanContents { get; set; }

        public virtual DbSet<EquipmentInventory> EquipmentInventories { get; set; }

        public virtual DbSet<InspectShift> InspectShifts { get; set; }

        public virtual DbSet<InspectSchedule> InspectSchedules { get; set; }

        public virtual DbSet<InspectViolation> InspectViolations { get; set; }

        public virtual DbSet<InspectRecord> InspectRecords { get; set; }

        public virtual DbSet<InspectRecordItem> InspectRecordItems { get; set; }

        public virtual DbSet<DefectInventory> DefectInventories { get; set; }

        public virtual DbSet<InspectItem> InspectItems { get; set; }

        public virtual DbSet<InspectPlanTeam> InspectPlanTeams { get; set; }

        public virtual DbSet<InspectPlanTeamTime> InspectPlanTeamTimes { get; set; }
    }
}
